<template>
  <div>
    <Spin :spinning="loading" tip="Loading...">
    <div style="padding-top: 1rem;"></div>
    <!-- 整车保修期 -->
      <FormPanel ref="formPanel" :list="formList" :cols="1" :formType="'add'" labelWidth="110" :isSubmitBtn="false" @formChange="formChangeHandle"/>

      <div style="padding-top: 1rem;"></div>
      <div
        :style="{
        position: 'absolute',
        left: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
      >
        <multiuse-button type="primary" :click="saveDialog.bind()">保 存</multiuse-button>
        <multiuse-button @click="closeDialog">关 闭</multiuse-button>
      </div>
    </Spin>

  </div>
</template>
<script>

export default {
  //父组件通过 props 向下传递数据给子组件，子组件通过 events 给父组件发送消息
  //要让子组件使用父组件的数据，需要通过子组件的 props 选项
  //这里用到的是静态props，子组件要显式地用 props 选项声明它期待获得的数据
  props: ['type', 'rowData'],
  data() {
    return {
      loading: false,
      formList: this.createFormList1(),
      visibleDrawer: false,
      visible: false,
      fetchParams: {}, //ipa 接口
      selectedRows: [], //选中经销商
      saveData: null
    };
  },
  components: {
   
  },
  //creadted钩子函数主要是用来初始化数据(vue模板渲染前)
  async created() {
    await this.chuqi();
    //回显
    await this.getDetailFun(this.rowData.vpId);
  },
 //mounted钩子函数一般是用来向后端发起请求拿到数据以后做一些业务处理。（vue模板渲染后）
  mounted() {
  },
  methods: {
     formChangeHandle(val) {
      console.log(val);
      this.saveData = val;
    },
    //初始化页面
    async chuqi(){
      console.log("进来了")
      const res = await getPartType({ type: 5584 });
      if (res.resultCode == 200) {
        this.formList.find(x => x.fieldName == 'vpType').initialValue = '';
        this.formList.find(x => x.fieldName == 'vpType').itemList = res.data.map(y => ({ text: y.codeCnDesc, value: y.codeId }));
      }
    },
 
    //编辑弹窗的取消操作
    closeDialog() {
      this.$emit('close', { visible: false, data: this.selectedRows, type: 'close' });
    },
    //编辑弹窗的保存
    async saveDialog() {

    },


    //创建编辑页面的表单面板
    createFormList1() {
      return [
      
        {
          type: 'INPUT',
          label: '保修里程',
          fieldName: 'vpMile',
          placeholder: '请输入保修里程...',
          rules: [
            {
              required: true,
              validator: (rule, value, callback) => {
                if (!value) {
                  return callback(new Error('请输入保修里程...'));
                }
                if (!Number.isInteger(Number(value))) {
                  return callback(new Error('请输入数字值...'));
                }
                callback();
              },
              trigger: ['blur', 'change'],
            },
          ],
          unitRender: () => {
            return <span>(KM)</span>;
          },
          offsetRightCols: 1
        }];
    }
  }
};
</script>
<style lang="less" scoped></style>